﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace AltimilliaLibrary
{
  public class Map
  {
    public List<Terrain> Terrains { get; set; }
    public WalkableLayer Layer { get; set; }

    public Map(List<Terrain> Terrain, WalkableLayer layer)
    {
      this.Terrains = Terrain;
      this.Layer = layer;
    }

    public void Draw(SpriteBatch batch)
    {
      int x = 0;
      int y = 0;

      foreach (Terrain terrain in Terrains)
      {
        y=0;
        foreach (TileRow row in terrain.TileRowList)
        {
          x=0;
          foreach (Tile tile in row.Tiles)
          {
            batch.Draw(terrain.Texture, new Rectangle((x * terrain.tilewidth) + (terrain.tilewidth / 2),
                                                     (y * terrain.tileheight) + (terrain.tileheight / 2),
                                                     terrain.tilewidth, terrain.tileheight),
                       terrain.Rectangle(tile.Position), Color.White, tile.Rotation, new Vector2(terrain.tilewidth / 2, terrain.tileheight / 2),
                       SpriteEffects.None, 0f);
            x++;
          }
          y++;
        }
      }
    }
  }
}
